using System.Windows;
using System.Windows.Controls;
using Common;

namespace ProjectView.ProjectControls
{
	internal class DataGridCellEditSelector : DataTemplateSelector
	{
		public DataTemplate Template { get; set; }

		public override DataTemplate SelectTemplate(object item, DependencyObject container)
		{
			FrameworkElement frameworkElement = container as FrameworkElement;
			ContentPresenter contentPresenter = container as ContentPresenter;
			DataGridCell dataGridCell = contentPresenter.Parent as DataGridCell;
			AQTargetDataRow aQTargetDataRow = dataGridCell.DataContext as AQTargetDataRow;
			if (aQTargetDataRow != null)
			{
				if (aQTargetDataRow.ColumnItem.ToString() == Utility.GetMessage("Prj_Dye"))
				{
					Template = DataTemplateCreator.CreateComboBoxDataTemplate("Channel" + dataGridCell.Column.DisplayIndex, "Dyes[" + (dataGridCell.Column.DisplayIndex - 1) + "]", typeof(UserControl).Name, true);
				}
				else if (aQTargetDataRow.ColumnItem.ToString() == Utility.GetMessage("Prj_Excitation-Emission") || aQTargetDataRow.ColumnItem.ToString() == Utility.GetMessage("Prj_Select"))
				{
					Template = DataTemplateCreator.CreateComboBoxDataTemplate("Channel" + dataGridCell.Column.DisplayIndex, "DefaultTargetNames", typeof(UserControl).Name, true);
				}
				else
				{
					Template = frameworkElement.FindResource("TargetComboBoxDataTemplate" + dataGridCell.Column.DisplayIndex) as DataTemplate;
				}
			}
			return Template;
		}
	}
}
